<script setup lang="ts">
// 定义 props 数据父传子
const props = defineProps<{
    money: number
    car: string
    house: string
}>()

// 定义 emit 数据子传父
const emits = defineEmits<{
    'update:money': [money: number]
    'update:car': [money: string]
    'update:house': [money: string]
}>()
const addMoney = () => {
    // 调用父组件传过来的函数
    emits('update:money', props.money + 10000)
}
</script>

<template>
    <div class="child-page" style="border: 1px solid red">
        <p>钱包: {{ money }}</p>
        <button @click="addMoney">发工资了</button>
        <p>----------------------</p>
        <p>车: {{ car }}</p>
        <button @click="emits('update:car', '五菱宏光')">换车</button>
        <p>----------------------</p>
        <p>住处: {{ house }}</p>
        <button @click="emits('update:house', '大别墅')">换车</button>
    </div>
</template>
